package com.zyz.I_多线程.创建方式.练习.方式二;

/**
 * @author: vick
 * @Date: 2025/3/21
 * @Description:
 * @version: 1.0
 */
public class Hare implements Runnable {
    @Override
    public void run() {
        String name = Thread.currentThread().getName();
        for (int i = 1; i <= 100; i++) {
            if (name.equals("兔子") && i%20 == 0) {
                try {
                    Thread.sleep(100);
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
            }
            System.out.println(name + "跑了" + i + "米");
        }
        System.out.println(name + "到达终点");
    }
}
